package com.ruoyi.web.controller.ibatis;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.data.domain.ParameterSingleT;
import com.ruoyi.data.service.IParameterSingleService;
import com.ruoyi.date.DateFormater;
import com.ruoyi.tool.domain.HouseRateToolT;
import com.ruoyi.tool.service.IHouseRateToolTService;
import com.ruoyi.util.SysParamKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 利息分摊Controller
 * 
 * @author lijie
 * @date 2023-08-04
 */
@RestController
@RequestMapping("/ibatis/interestTool")
public class HouseRateToolTController extends BaseController
{
    @Autowired
    private IParameterSingleService parameterSingleService;

    /**
     * 新增利息分摊
     */
    @PostMapping
    public AjaxResult getInterestTool(@RequestBody HouseRateToolT houseRateToolT)
    {
        Double interestMoney =  houseRateToolT.getMoney()*DateFormater.dateSubtractionTemp( houseRateToolT.getEndDate(),houseRateToolT.getStartDate())*houseRateToolT.getParamVal()/360;
        houseRateToolT.setInterestMoney(interestMoney);
        return AjaxResult.success(houseRateToolT);
    }

    /**
     * 获取利息分摊详细信息
     */
    @GetMapping
    public AjaxResult getRateYear()
    {
        ParameterSingleT parameterSingleT = new ParameterSingleT();
        parameterSingleT.setParamCode(SysParamKey.RATE.getKey());
        parameterSingleT = parameterSingleService.getSysParams(parameterSingleT);
        return AjaxResult.success(parameterSingleT);
    }

}
